package msi.gama.display.java3d.coordinate;

import javax.media.j3d.Appearance;
import javax.media.j3d.ColoringAttributes;
import javax.media.j3d.GeometryArray;
import javax.media.j3d.LineArray;
import javax.media.j3d.Shape3D;
import javax.vecmath.Color3f;
import javax.vecmath.Point3f;

/**
 * minhvv, p18, IFI, TPE 01/2014 - 07/2014
 */

public class LineObject {

	private Shape3D shape;
	private Point3f[] points;
	private Color3f color;

	public LineObject(Point3f p1, Point3f p2, Color3f color) {
		points = new Point3f[2];
		points[0] = p1;
		points[1] = p2;
		this.color = color;

		createShape();
	}

	private void createShape() {
		LineArray lines = new LineArray(2, GeometryArray.COORDINATES);
		lines.setCoordinates(0, points);

		Appearance app = new Appearance();
		ColoringAttributes ca = new ColoringAttributes();
		ca.setColor(this.color);
		app.setColoringAttributes(ca);

		shape = new Shape3D(lines, app);
	}

	public Shape3D getShape() {
		return shape;
	}

}
